function quality = uqi(img1,img2) 

meanimg1 = mean(img1);
meanimg2 = mean(img2);

cm = cov(img1,img2);
varimg1 = cm(1,1);
varimg2 = cm(2,2);
covimg1img2 = cm(1,2);

down = (varimg1 + varimg2)*(meanimg1*meanimg1 + meanimg2*meanimg2);
quality = 4 * covimg1img2 * meanimg1 * meanimg2 / (down);